import Player from '../music'

const list = function (player){
    const util = Player.util;
    const controlEl = player.controls;
    
    const list = util.createDom('xg-play-list', `
        <span class="tip" style="display: none;">已添加到播放列表</span>
        <a href="javascript:;" title="播放列表" class="icn icn-list">${0}</a>
    `, {}, 'xgplayer-play-list');
    
    controlEl.appendChild(list);
    
    list.addEventListener('click', function (e) {
        player.emit('clickList', list);
    })

    player.on('change', () => {
        list.children[1].innerText = player.list.length;
    })
}

Player.install('list', list)
